const app = getApp()
var template = require('../../template/template.js');
Page({

    /**
     * 页面的初始数据
     */
    /*data: {
      menuList:'',
      result:'',
    },*/

    /**
     * 生命周期函数--监听页面加载
     */
  onLoad: function (options) {
    var tabnum = app.globalData.tabnum
    template.tabbar("tabBar", 1, this, tabnum)//0表示第一个tabbar
        //页面加载完成提示
        this.data.styles = {};
        this.data.styles.curtainViewWidth = 600;
        this.data.styles.curtainViewRight = -(this.data.styles.curtainViewWidth + 100);
        if (options.id) {
            this.data.tabIndex = options.id;
            this.data.list = new Array(4);
            this.changeTab(options.id);

        } else {
            this.data.tabIndex = 0;
            this.data.list = new Array(4);
            this.changeTab(0);
        }
        //console.log(this.data.tabIndex);
        var that = this;
        wx.getSystemInfo({
            success: function (info) {
                that.data.windowHeight = info.windowHeight;
                that.setData(that.data);
            }
        });
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },
    onReady: function (options) {
      //初始化数据
      this.getItemsarray();
     
    },
    //获取所有导航
    getItemsarray: function () {
      var that = this;
     wx.request({
       //url: 'https://xcx.chenjiudenanren.com/inter/Intro/index.html',
       url: 'https://xcx.chenjiudenanren.com/inter/Intro/placeall',
       header: {
          "Content-Type": "applciation/json"
        },
        success: function (res) {
          console.log(res.data)
          that.setData({
            menuList: res.data,
          //  data: res.data,
          })
        },
        fail: function (err) {
          console.log(err)
        },
      })

    },

    tabItemClick: function (event) {
        this.changeTab(parseInt(event.currentTarget.id.split("_")[1]));
    },
    swiperChange: function (event) {
        this.changeTab(event.detail.current);
    },
    changeTab: function (index) {
        this.data.tabIndex = index;
        this.setData(this.data);
        //console.log(index);
    },
   /* onPullDownRefresh: function () {
        console.log('refresh');
        wx.showToast({
            title: '加载中...',
            icon: 'loading',
            duration: 1500
        })
        this.onLoad({ id: this.data.tabIndex });
        //停止下拉刷新的动画
        wx.stopPullDownRefresh();
    },*/
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})